{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1. Trajectory Automation"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "All the task classes in VLABench have the function `get_expert_skill_sequence`, the function provide the execuable object-centric operation sequences in the environment. Here we load task `play_texas_holdem` as an example, see the initial image rendered in environment."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import os\n",
    "import mediapy as media\n",
    "from VLABench.robots import *\n",
    "from VLABench.tasks import *\n",
    "from VLABench.envs import load_env\n",
    "\n",
    "task_name = \"texas_holdem\"\n",
    "env = load_env(task_name)\n",
    "env.reset()\n",
    "media.show_image(env.render(camera_id=2, height=640, width=640))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can see the expert skill sequence that should be carried out."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "expert_skill_sequence = env.get_expert_skill_sequence()\n",
    "expert_skill_sequence"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Carry out the skill sequence and the correspond observations and waypoints would be recorded."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "key_frames = []\n",
    "for skill in expert_skill_sequence:\n",
    "    obs, waypoint, stage_success, task_success = skill(env)\n",
    "    key_frames.extend([o['rgb'][2] for o in obs])\n",
    "    break\n",
    "media.show_video(key_frames, fps=10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The above describes the main logic of trajectory generation. For detailed generation scripts, please refer to the `scripts/trajectory_generation.py`."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "vlabench",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
